package com.letoken.platform.app.controller;

import com.letoken.platform.app.service.AppUserTeamService;
import com.letoken.platform.pub.annotation.auth.NotAuthorization;
import com.letoken.platform.pub.annotation.pub.Trim;
import com.letoken.platform.pub.req.PageData;
import com.letoken.platform.pub.req.QueryReqBase;
import com.letoken.platform.pub.res.ApiResponse;
import com.letoken.platform.repo.app.req.team.AppBindInvitationCodeReq;
import com.letoken.platform.repo.app.req.team.ConsumerValueHistoryReq;
import com.letoken.platform.repo.app.res.assets.QueryTokenAssetsPriceRes;
import com.letoken.platform.repo.app.res.team.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author letokenlabs
 * @date 2022/11/21$
 */
@RestController
@RequestMapping("/team")
@Api(tags = "我的-我的团队", description = "团队接口")
public class AppUserTeamController {

    @Autowired
    private AppUserTeamService appUserTeamService;


    @GetMapping("/info")
    @ApiOperation(value = "团队基本信息", notes = "查询我的团队基本信息")
    public ApiResponse<QueryTeamRes> queryTeamInfo() {
        return ApiResponse.create(appUserTeamService.queryTeamInfo());
    }

    @PostMapping("/members")
    @ApiOperation(value = "团队成员列表", notes = "查询团队成员列表")
    public ApiResponse<PageData<QueryTeamMemberRes>> queryTeamMembers(@Validated @RequestBody QueryReqBase req) {
        return ApiResponse.create(appUserTeamService.queryTeamMembers(req));
    }

    @GetMapping("/level")
    @ApiOperation(value = "生态等级建设-查询", notes = "查询我的生态等级建设")
    public ApiResponse<QueryTeamLevelRes> queryTeamLevel() {
        return ApiResponse.create(appUserTeamService.queryTeamLevel());
    }

    @GetMapping("/level/config")
    @ApiOperation(value = "生态等级建设-配置信息", notes = "查询生态等级建设配置信息")
    public ApiResponse<List<QueryTeamLevelInfoRes>> queryTeamLevelInfo() {
        return ApiResponse.create(appUserTeamService.queryTeamLevelInfo());
    }

    @Trim
    @PostMapping("/bind/invitecode")
    @ApiOperation(value = "绑定邀请码", notes = "绑定邀请码")
    public ApiResponse<AppBindInvitationCodeRes> bindInvitationCode(@Validated @RequestBody AppBindInvitationCodeReq req) {
        return ApiResponse.create(appUserTeamService.bindInvitationCode(req));
    }


    @GetMapping("/consumerInfo")
    public ApiResponse<QueryConsumerInfoRes> consumerInfo() {
        return ApiResponse.create(appUserTeamService.consumerInfo());
    }

    @PostMapping("/consumerValueHistory")
    public ApiResponse<PageData<ConsumerValueHistoryRes>> consumerValueHistory(@RequestBody @Validated ConsumerValueHistoryReq req) {
        return ApiResponse.create(appUserTeamService.consumerValueHistory(req));
    }

}
